package com.hexacta.hrs.test.data;

import java.util.List;
import java.util.Map;

import org.vectrics.event.EventType;

/**
 * Test data dependency creator for the EventType class.
 * 
 * @author tpollak
 */
public class EventTypeTestDataDependencyCreator extends AbstractTestDataDependencyCreator {

    public EventTypeTestDataDependencyCreator(List<TestDataDependencyCreator> dependencies) {
        super(dependencies);
    }

    public void createDependentTestData(Map<String, Object> context) {
        this.createAndInsertEventType(context, "hired.person", "Hired person", "event.hdlr.person.hired");
        this.createAndInsertEventType(context, "interview.sched", "Interview scheduled", "interview.sched");
        this.createAndInsertEventType(context, "job.candidate.created", "Job Candidate Created",
                "event.hdlr.job.cand.created");
        this.createAndInsertEventType(context, "job.candidate.sts.chg", "Job Candidate Created",
                "event.hdlr.job.cand.sts.chg");
        this.createAndInsertEventType(context, "job.chg", "Job Changed", "event.hdlr.job.changed");
        this.createAndInsertEventType(context, "job.created", "Job Posting Created", "event.hdlr.job.created");
        this.createAndInsertEventType(context, "job.sts.chg", "Job Posting Created", "event.hdlr.job.sts.chg");
        this.createAndInsertEventType(context, "person.created", "Person Created", "event.hdlr.person.created");
        this.createAndInsertEventType(context, "user.created", "User Created", "event.hdlr.user.created");
    }

    private EventType createAndInsertEventType(Map<String, Object> context, String code, String description,
            String handlerClass) {
        EventType eventType = this.createEventType(code, description, handlerClass);
        this.insertCodedObject(eventType);
        return eventType;
    }

    private EventType createEventType(String code, String description, String handlerClass) {
        EventType eventType = new EventType();
        eventType.setCode(code);
        eventType.setDescription(description);
        eventType.setHandlerClass(handlerClass);
        eventType.setVoided(false);
        return eventType;
    }
}
